package com.lz.football.module.ladderMatch.item
{
	import com.common.utils.Reflection;
	import com.liangzhong.constants.TipsConst;
	import com.liangzhong.model.AppData;
	import com.liangzhong.model.compete.vo.CompeteMatchResultVo;
	import com.lz.football.module.base.IComponent;
	
	import common.BaseView.IItemMouseEvent;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	import lz.controls.managers.TipsManager;
	
	public class MatchResultItem extends Sprite implements IComponent, IItemMouseEvent
	{
		/**
		 * 
		 */
		private var _skin:MovieClip;
		/**
		 * 
		 */
		private var resultIcon:MovieClip;
		/**
		 * 
		 */
		private var _tips:String;
		public function MatchResultItem()
		{
			super();
		}
		
		public function initUI(view:Object=null):void
		{
			_skin = Reflection.createInstance("com.lz.modul.ladderMatch.resultItem");
			this.addChild(_skin);
			resultIcon = _skin.resultIcon;
			resultIcon.gotoAndStop(4);
			addEvtListener();
		}
		
		public function addEvtListener():void
		{
			this.addEventListener(MouseEvent.ROLL_OUT,onMouseRollOut);
			this.addEventListener(MouseEvent.ROLL_OVER,onMouseRollOver);
		}
		
		/**
		 *重置 
		 * 
		 */
		public function reset():void
		{
			_tips = null;
			resultIcon.gotoAndStop(4);
			removeEvtListener();
		}
		public function setData($vo:CompeteMatchResultVo):void
		{
			if($vo.ggold == $vo.hgold)//比赛结果为平
			{
				resultIcon.gotoAndStop(1);
			}else
			{
				if($vo.hId == AppData.getInstance().clubDatamanager.clubInfo.clubid)//主队为自己
				{
					if($vo.hgold > $vo.ggold)//赢
					{
						resultIcon.gotoAndStop(3);
					}else
					{
						resultIcon.gotoAndStop(2);
					}
				}else
				{
					if($vo.hgold > $vo.ggold)//赢
					{
						resultIcon.gotoAndStop(2);
					}else
					{
						resultIcon.gotoAndStop(3);
					}
				}
			}
			_tips = $vo.homeName + "  " + $vo.hgold + ":" + $vo.ggold + "  " + $vo.guname;
			addEvtListener();
		}
		public function removeEvtListener():void
		{
			this.removeEventListener(MouseEvent.ROLL_OUT,onMouseRollOut);
			this.removeEventListener(MouseEvent.ROLL_OVER,onMouseRollOver);
		}
		
		public function destroyView():void
		{
		}
		
		public function onMouseRollOut(event:MouseEvent):void
		{
			TipsManager.hide();
		}
		
		public function onMouseRollOver(event:MouseEvent):void
		{
			if(tips == null)return;
			TipsManager.show(TipsConst.BASETIPS,{tip:tips});
		}
		
		public function onMouseClick(event:MouseEvent):void
		{
		}
		
		public function get tips():Object
		{
			return _tips;
		}
		
		public function set tips(value:Object):void
		{
		}
	}
}